package com.lagou.homework134;

import java.util.Scanner;

/**
 * 使用 List 集合实现简易的学生信息管理系统，要求打印字符界面提示用户选择相应的功能，
 * 根据用户输入的选择去实现增加、删除、修改、查找以及遍历所有学生信息的功能。
 */
public class StudentInfoManagerTest {
    public static void main(String[] args) {
        StudentInfoManager.add(new Student(1, "huawei", 10));
        initUI();
    }

    public static void initUI() {
        System.out.println();
        System.out.println("-----------------------学生信息管理系统------------------");
        System.out.println("                1.添加  2.修改   3.查询  4.删除                    ");
        System.out.println("请选择：");
        Scanner scanner = new Scanner(System.in);
        int input = scanner.nextInt();
        String name;
        switch (input) {
            case 1:
                System.out.println("【添加】请输入学号，姓名，年龄：");
                int id = scanner.nextInt();
                name = scanner.next();
                int age = scanner.nextInt();
                StudentInfoManager.add(new Student(id, name, age));
                break;
            case 2:
                StudentInfoManager.findAll();
                System.out.println("【修改】请输入序号，要修改的姓名");
                int index = scanner.nextInt();
                name = scanner.next();
                StudentInfoManager.update(index, name);
//                findAll();
                break;
            case 3:
                System.out.println("【查询】请输入姓名");
                name = scanner.next();
                Student stu = StudentInfoManager.find(name);
                System.out.println("查询结果：" + stu);
                break;
            case 4:
                System.out.println("【删除】请输入姓名");
                name = scanner.next();
                StudentInfoManager.delete(name);
                break;
            case 0:
                System.exit(0);
                break;
            default:
                break;
        }
        initUI();
    }

}
